<?php

class Application_Form_Registry extends Zend_Form
{
    private $view;
    
    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        $this->view = Zend_Layout::getMvcInstance()->getView();
        $this->setAttrib("id","registry");
        //create element username
        $username = $this->createElement("text","username");
        $username->setLabel("User name:")
                     ->setRequired()
                     ->addValidators(array(
                        array("NotEmpty",false,array("messages"=>array('isEmpty'=>"User name is required!"))),
                     ))
                     ->setAttrib("size","30");            
        $this->addElement($username);
        
        //create element password
        $password = $this->createElement("password","password");
        $password->setLabel("Password:")
                     ->setAttrib("size","50");            
        $this->addElement($password);
        
        //create element password
        $repassword = $this->createElement("password","repassword");
        $repassword->setLabel("Confirm Password:")
                   ->setAttrib("size","50");            
        $this->addElement($repassword);
        
         // create group
       $this->addDisplayGroup(array(
            $username,
            $password,
            $repassword
       ),"account",array('class'=>'display-group',"legend"=>"Account information"));
       
       
       //create element fullname
        $fullname = $this->createElement("text","fullname");
        $fullname->setLabel("Full name:")
                     ->setAttrib("size","50");            
        $this->addElement($fullname);
        
       //create element phone
        $phone = $this->createElement("text","phone");
        $phone->setLabel("Phone:")
                     ->setAttrib("size","50");            
        $this->addElement($phone);
        
        //create element email
        $email = $this->createElement("text","email");
        $email->setLabel("Email:")
                     ->setAttrib("size","50");            
        $this->addElement($email);
        
        //create element address
        $address = $this->createElement("text","address");
        $address->setLabel("Address:")
                     ->setAttrib("size","100");            
        $this->addElement($address);
        
        //create element visa code
        $visa = $this->createElement("text","visa");
        $visa->setLabel("Visa card number:")
                     ->setAttrib("size","50");            
        $this->addElement($visa);
        
         // create group
       $this->addDisplayGroup(array(
            $fullname,
            $phone,
            $email,
            $address,
            $visa
       ),"contact",array('class'=>'display-group',"legend"=>"Contact information"));
                        
       
       //create element $security
        $captchar = new Zend_Form_Element_Captcha("captcha", array("label"=>"",
                                                                   "captcha"=>array(
                                                                        "captcha"=>"Image",
                                                                        "name"=>"SecurityCode",
                                                                        'wordLen' => 5,  
                                                                        'expiration' => 300,
                                                                        'font' => APPLICATION_PATH.'/../public/images/captcha/font/arial.ttf' ,
                                                                        'fontsize'=>25,
                                                                        'imgDir'  => APPLICATION_PATH.'/../public/images/captcha/',  
                                                                        'imgUrl'  => $this->view->baseUrl('/images/captcha/'),
                                                                        'lineNoiseLevel' =>0,
                                                                        'DotNoiseLevel' =>20,
                                                                        'height' =>70,
                                                                        'width' =>200
                                                                   )));
        $this->addElement($captchar);
        
         // create group
       $this->addDisplayGroup(array(
            $captchar
       ),"security",array('class'=>'display-group',"legend"=>"Security code"));
       
       
       // create submit button
        $submit = $this->createElement("submit","submit");
        $submit->setLabel("Registry")
               ->setAttrib("class","btn-black");
        $this->addElement($submit);
        
        $reset = $this->createElement("reset","reset");
        $reset->setLabel("Reset")
               ->setAttrib("class","btn-red");
        $this->addElement($reset);
        
        // create group
       $this->addDisplayGroup(array(
            $submit,
            $reset
       ),"buttons",array('class'=>'buttons'));
       
          
    }

}

